home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
SEARCH
/
RUBICON
/
RBCOMPAR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-10-21
|
4KB
|
159 lines
{*********************************************************}
{* RBCOMPAR.PAS 1.20 *}
{* Copyright (c) Tamarack Associates 1996. *}
{* All rights reserved. *}
{*********************************************************}
{$B-} {* Boolean evaluation *}
{$G+} {* Generate 286 code *}
{$X+} {* eXtended syntax *}
unit rbCompar;
interface
uses
{$IFDEF WIN32}
Windows,
{$ELSE}
WinTypes, WinProcs,
{$ENDIF}
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DB, DBTables, Grids, DBGrids, ExtCtrls,
StBase, taTools, taRubicn;
type
TForm1 = class(TForm)
MakeDictionary1: TMakeDictionary;
MakeDictionary2: TMakeDictionary;
Table1: TTable;
Table2: TTable;
DataSource1: TDataSource;
DataSource2: TDataSource;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
RecNoLabel: TLabel;
CompareBtn: TButton;
procedure CompareBtnClick(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
FClosing : BOOLEAN;
FContinue : WORD;
public
{ Public declarations }
PROCEDURE Process;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Edit1Exit(Sender: TObject);
begin
IF FClosing THEN EXIT;
WITH Table1 DO
BEGIN
Close;
TableName := AliasToPath(Edit1.Text);
Open;
IF NOT CheckStructure(Table1) THEN
BEGIN
Close;
RAISE EDictionary.Create('Invalid WordsTable structure')
END
END
end;
procedure TForm1.Edit2Exit(Sender: TObject);
begin
IF FClosing THEN EXIT;
WITH Table2 DO
BEGIN
Close;
TableName := AliasToPath(Edit2.Text);
Open;
IF NOT CheckStructure(Table2) THEN
BEGIN
Close;
RAISE EDictionary.Create('Invalid WordsTable structure')
END
END
end;
procedure TForm1.CompareBtnClick(Sender: TObject);
begin
WITH CompareBtn DO
IF Caption = 'Compare' THEN
TRY
Caption := 'Stop';
Process;
FINALLY
Caption := 'Compare'
END
ELSE FContinue := mrCancel
end;
PROCEDURE TForm1.Process;
VAR RecNum : LONGINT;
V1,V2 : TVerifyRecord;
B1,B2 : TtaBits;
P1,P2 : POINTER;
BEGIN
IF NOT Table1.Active OR NOT Table2.Active THEN EXIT;
RecNum := 0;
FContinue := mrOk;
Table1.First;
Table2.First;
WHILE NOT Table1.EOF AND NOT Table2.EOF AND (FContinue = mrOk) DO
BEGIN
INC(RecNum);
RecNoLabel.Caption := IntToStr(RecNum);
Application.ProcessMessages;
MakeDictionary1.VerifyRecord(V1);
MakeDictionary2.VerifyRecord(V2);
B1 := TtaBits(V1.CompressedSize);
B2 := TtaBits(V2.CompressedSize);
P1 := POINTER(V1.Buffer);
P2 := POINTER(V2.Buffer);
IF Table1.Fields[wtWord].AsString <> Table2.Fields[wtWord].AsString THEN
FContinue := MessageDlg('Words differ',mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND
(Table1.Fields[wtWordCount].AsInteger <> Table2.Fields[wtWordCount].AsInteger) THEN
FContinue := MessageDlg('WordCounts differ',mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND
(Table1.Fields[wtBlobSize].AsInteger <> Table2.Fields[wtBlobSize].AsInteger) THEN
FContinue := MessageDlg('BlobSizes differ',mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND (B1.Count <> B2.Count) THEN
FContinue := MessageDlg('Counts differ (' + IntToStr(B1.Count) + ':' +
IntToStr(B2.Count) + ')', mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND (B1.FirstSet <> B2.FirstSet) THEN
FContinue := MessageDlg('FirstSets differ (' + IntToStr(B1.FirstSet) + ':' +
IntToStr(B2.FirstSet) + ')', mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND (B1.LastSet <> B2.LastSet) THEN
FContinue := MessageDlg('LastSets differ (' + IntToStr(B1.LastSet) + ':' +
IntToStr(B2.LastSet) + ')', mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND (B1.CompareBits(B2) <> 0) THEN
FContinue := MessageDlg('Bitsets differ',mtError,[mbOk,mbCancel],0);
Table1.Next;
Table2.Next;
END
END;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FClosing := TRUE
end;
end.